package Stream;

import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @Author Mr.Wen
 * @Version 1.0
 * stream实例化的三种方式
 */
public class StreamInstance {
    @Test/*通过集合*/
    public void test1() {
        List<Employee> employees = EmployeeData.getEmployees();
        /*顺序流*/
        Stream<Employee> stream = employees.stream();
        /*并行流*/
        Stream<Employee> parallelStream = employees.parallelStream();
    }

    @Test/*通过数组*/
    void test2() {
        Integer[] arr = new Integer[]{1, 23, 543};
        Stream<Integer> stream = Arrays.stream(arr);

        int[] arr2 = new int[]{1, 2, 3, 4, 5};
        IntStream stream1 = Arrays.stream(arr2);
    }

    @Test/*通过stream的of api*/
    void test3() {
        Stream<Integer> stream = Stream.of(1, 2, 3, 4, 5);
    }
}
